package com.rybbaby.tss.front.tssMemberFollowUpRecord.dao.imp;

import com.rybbaby.tss.core.web.dao.imp.GenericDao;
import com.rybbaby.tss.front.tssMemberFollowUpRecord.dao.ITssMemberFollowUpRecordDao;
import com.rybbaby.tss.front.tssMemberFollowUpRecord.entity.TssMemberFollowUpRecord;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * @author 雷春琼
 * @description 缴费表数据库操作实现
 * @createDate 2017-08-10 上午12:22:55
 */
@Repository
public class TssMemberFollowUpRecordDaoImp extends GenericDao<TssMemberFollowUpRecord> implements ITssMemberFollowUpRecordDao {

    @Override
    public List<Map<String, Object>> getDetailListByMemberId(String memberId, Integer type) {
        List<Map<String, Object>> detaillList=new ArrayList<>();
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT\n" +
                "\tfu.createTime,\n" +
                "\tfu.content,\n" +
                "\tfu. STATUS status,\n" +
                "\tfu.nextFollowUpTime,\n" +
                "\tfu.subscribeAuditionTime\n" +
                "FROM\n" +
                "\ttss_member_follow_up_record fu\n" +
                "LEFT JOIN tss_student ts ON ts.id = fu.memberId\n" +
                "LEFT JOIN tss_member_package mp ON mp.memberId = ts.id\n" +
                "WHERE\n" +
                "\tfu.memberId =?\n");
        if (type==0){
            detaillList= this.findForJdbc(sb.toString(), new Object[]{memberId});
        }
        if (type != 0) {
            sb.append("AND mp.type =?");
            detaillList= this.findForJdbc(sb.toString(), new Object[]{memberId,type});
        }
        return detaillList;
    }
}
